//
//  PersonalContentViewMaker.m
//  nonghubao
//
//  Created by 王文彬 on 13-3-10.
//  Copyright (c) 2013年 mypocketbaby. All rights reserved.
//

#import "PersonalContentViewLightMaker.h"
#import "Helper.h"
#import "Config.h"
#import "ASImageView.h"

@implementation PersonalContentViewLightMaker

+ (void)makePrototype:(UIView *)view
{
    if (view) {
        //头像
        ASImageView *auatarImageView = [[ASImageView alloc] initWithFrame:CGRectMake(10, 9, 30, 30)];
        [view addSubview:auatarImageView];
        
        //名字
        UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 9, 150, 15)];
        nameLabel.font = _SYS_FONT_002;
        nameLabel.backgroundColor = [UIColor clearColor];
        [view addSubview:nameLabel];
        
        //日期
        UILabel *dateLabel = [[UILabel alloc] initWithFrame:CGRectMake(50, 26, 150, 15)];
        dateLabel.backgroundColor = [UIColor clearColor];
        dateLabel.font = _SYS_FONT_001;
        dateLabel.textColor = _SYS_COLOR_002;
        [view addSubview:dateLabel];

        //更多
        UILabel* moreLabel = [[UILabel alloc] initWithFrame:CGRectMake(220, 14, 70, 15)];
        moreLabel.backgroundColor = [UIColor clearColor];
        moreLabel.font = _SYS_FONT_002;
        moreLabel.textColor = _SYS_COLOR_002;
        moreLabel.text = _L(@"title_86");
        [view addSubview:moreLabel];
    }
}


// 计算一个动态的高度
+ (float)heightWithDictionary:(NSDictionary *)data
{
    return 45.0f;
}

// 根据数据重新绘制动态内容
+ (void)drawContentView:(UIView *)view withDictionary:(NSDictionary *)data
{
    //绘制头像
    [((ASImageView *)[view.subviews objectAtIndex:0]) setImageURL:[NSURL URLWithString:[data objectForKey:@"creatorPreviewAvatar"]] andSourceImageURL:nil forStyle:PictureStyleAvartPreview];
    
    //姓名
    ((UILabel *)[view.subviews objectAtIndex:1]).text = [data objectForKey:@"creatorRealName"];
    
    //日期
    ((UILabel *)[view.subviews objectAtIndex:2]).text = [Helper formatDateString:[data objectForKey:@"createTime"]];
}

@end
